#!/usr/bin/env python3
# -*- coding=utf-8 -*-
# 题目：有n个人围成一圈，顺序排号。
# 从第一个人开始报数（从1到3报数），
# 凡报到3的人退出圈子，
# 问最后留下的是原来第几号的那位。


def f1():
    a = []
    for i in range(34):
        a.append(i + 1)
    i = 0  # 递增
    j = 0  # 删除的个数
    k = 0  # 下标
    length = len(a)
    while j != length - 1:
        if a[i] != 0:
            k += 1
            if k == 3:
                a[i] = 0
                j += 1
                k = 0
        i = (i + 1) % length
    else:
        i = 0
        while a[i] == 0:
            i += 1
        print(f"留下的是第{i}个。")


f = f1
if __name__ == "__main__":
    f()
